package com.lzj.demo.design.chain.fzw.chain;

import cn.hutool.core.date.DateUtil;
import com.lzj.demo.design.chain.fzw.AuthInfo;

import java.util.Date;
import java.util.Objects;
/**
 * 三级审批
 * */
public class Level3AuthLink extends AuthLink {
    public Level3AuthLink(String levelUserId, String levelUserName) {
        super(levelUserId, levelUserName);
    }

    @Override
    public AuthInfo doAuth(String uId, String orderId, Date authDate) {
        Date date = AuthService.queryAuthInfo(levelUserId,orderId);
        if(Objects.isNull(date)){
            return new AuthInfo("001","单号: ",orderId," 状态:待三级负责人审批 ",levelUserName);
        }

        AuthLink next = super.getNextAuth();

        if(Objects.isNull(next)){
            return new AuthInfo("001","单号: "
                    ,orderId," 状态:三级负责人审批完成 ","时间 ", DateUtil.format(date,"yyyy-MM-dd HH:mm:ss")," 审批人 ",levelUserName);
        }

        return next.doAuth(uId,orderId,authDate);
    }
}
